/*
 * @Author: january.cjy
 * @Date: 2021-09-27 19:46:13
 * @Last Modified by: january.cjy
 * @Last Modified time: 2021-09-27 21:01:05
 */
#pragma once

#include "clang/AST/AST.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/SourceManager.h"
#include "clang/AST/ParentMapContext.h"
#include <CmgFileFeature.h>
#include "clang/AST/ASTTypeTraits.h"
namespace cmg {

using namespace clang;
using namespace llvm;

class CmgRecursiveASTVisitor
    : public RecursiveASTVisitor<CmgRecursiveASTVisitor> {
public:

  using base = RecursiveASTVisitor<CmgRecursiveASTVisitor>;
  explicit CmgRecursiveASTVisitor(ASTContext &ctx, SourceManager &sm,FileFeature &feature);
  //bool VisitDecl(Decl *d);
  // bool VisitTranslationUnitDecl(TranslationUnitDecl *tranc);
  bool VisitFunctionDecl(FunctionDecl *func);
  bool VisitVarDecl(VarDecl *varc);
  bool VisitTypedefDecl(TypedefDecl *typec);
  bool VisitTagDecl(TagDecl *tagc);
  bool VisitClassTemplateDecl(ClassTemplateDecl *templatec);
  bool VisitFunctionTemplateDecl(FunctionTemplateDecl *templatefunc);
  void ShowOrExport(){
    fileFeature.ShowOrExport();
  }
  int isGlobal(DynTypedNode node);
  void countSymbol(int isDeclOrDef,unsigned int& decl,unsigned int& def);

private:
  ASTContext &ctx;
  SourceManager &sm;
  FileFeature &fileFeature;
};

} // namespace cmg